<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 扩展运算符可以将数组拆分成以逗号分隔的参数序列
        let arr = ['a', 'b', 'c'];
        // ...arr  // 等价于  'a', 'b', 'c'
        console.log(...arr);
        console.log('a', 'b', 'c');
        console.log('---------------------');

        // 扩展运算符应用于数组合并
        // 方法一
        let ary1 = [1, 2, 3];
        let ary2 = [4, 5, 6];
        // ...ary1  // 1,2,3
        // ...aey2 // 4,5,6
        let ary3 = [...ary1, ...ary2];
        console.log(ary3);
        console.log('----------------------');

        // 方法二
        let arr1 = [1, 2, 3];
        let arr2 = [4, 5, 6];
        arr1.push(...arr2); // push 追加元素
        console.log(arr1);
    </script>
</body>

</html>